//
//  YWKeepWatchMission.m
//  maintain
//
//  Created by 郑想 on 16/2/19.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "MJExtension.h"
#import "YWKeepWatchMission.h"
#import "YWBuilding.h"

@implementation YWPatrolLineLocationRel
- (void)mj_keyValuesDidFinishConvertingToObject
{
    if (self.location) {
        self.locationId = self.location.locationId;
    }
}
@end

@implementation YWPatrolLineWeekRel
@end

@implementation YWPatrolLine
+ (NSDictionary*)mj_objectClassInArray
{
    return @{
        @"locationRels" : @"YWPatrolLineLocationRel",
        @"weekRels" : @"YWPatrolLineWeekRel"
    };
}
@end

@implementation YWKeepWatchMission
+ (NSArray *)mj_ignoredPropertyNames{
    return @[@"currentLooperTimeArray"];
}

+ (NSDictionary*)mj_objectClassInArray
{
    return @{ @"executors" : @"YWHandler",
              @"observers" : @"YWHandler"};
}
//+ (NSArray *)mj_ignoredPropertyNames
//{
//    return @[@"xxx"];
//}
- (void)mj_keyValuesDidFinishConvertingToObject{
    self.endDate += 86399000;//(23＊60*59+59)*1000
    if (self.building) {
        self.buildingId = self.building.buildingId;
    }
    NSMutableString *atUserName = [[NSMutableString alloc] init];
    [self.observers enumerateObjectsUsingBlock:^(YWHandler*  _Nonnull handler, NSUInteger idx, BOOL * _Nonnull stop) {
        if (atUserName.length && idx!=0) {
            [atUserName appendString:@","];
        }
        [atUserName appendString:[@(handler.uniqueId) stringValue]];
    }];
    self.observerIds = [NSString stringWithFormat:@"%@",atUserName];
}
@end

@implementation YWPatrolLineOption
+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{@"patrolLineId" : @"id",
             @"patrolLineName" : @"text"};
}
@end
